package book;
import book.Book;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: LXW
 * Date: 2021-12-09
 * Time: 11:43
 */
public class BookList {
    private Book[] books = new Book[10];   // 创建一个Book类型的数组
    private int size = 0;    // 图书的数量
    public BookList () {         // 构造方法，这里先放了三本书，方便后续测试
        books[0] = new Book("三国演义", "罗贯中", 100, "小说");
        books[1] = new Book("水浒传", "施耐庵", 100, "小说");
        books[2] = new Book("西游记", "吴承恩", 100, "小说");
        this.size = 3;   // 图书数量变为3
    }

    public int getSize() {
        return size;
    }

    public void setSize(int size) {
        this.size = size;
    }

    /**
     * 获取到pos位置的某本书并返回这本书的信息。
     * @param pos
     * @return
     */
    public Book getPos (int pos) {
        return this.books[pos];
    }

    /**
     * 在pos位置上添加某本书
     * @param pos
     * @param book
     */
    public void setPos (int pos, Book book) {
        this.books[pos] = book;
    }

}
